<template>
<div>
  <van-nav-bar
      title="填写订单"
      left-arrow
      @click-left="onClickLeft"
  />
<!-- 收货地址 -->
  <div class="address" @click="onEdit" v-if="objaddres">
    <van-icon name="arrow" class="icon" />
    <div><span :class='[{"addspan":objaddres.isDefault}]'>默认</span>&nbsp;&nbsp;<span class="span1">{{objaddres.address}}</span></div>
    <p style="margin-left:14px">{{objaddres.ress}}</p>
    <div style="margin-bottom:10px"><span class="span" >{{objaddres.name}}</span> <span class="span">{{objaddres.tel}}</span></div>
  </div>
  <van-contact-card add-text="添加默认地址" type="add" @click="onAdd" v-else/>
<!--  商品详情 -->
  <!-- 购物车商品列表 -->
  <van-row type="flex" style="overflow: hidden;margin-top:10px" justify="space-between" v-for="(item,index) in ShopList.CkeckedLiat">
    <van-col span="18">
      <!-- 商品列表 -->
      <van-card
          :num="item.selectedNum"
          :price="parseInt(item.selectedSkuComb.price/100).toFixed(2)"
          desc="软件测试数据"
          :title="item.name"
          :thumb="item.img"
      >
        <template #footer>
          <van-row type="flex" justify="end">
            <van-col span="8" style="text-align:center;">小计:<span style="color: red;line-height: 28px">{{parseInt(item.selectedSkuComb.price/100)*item.selectedNum}}</span></van-col>
            <van-col span="1"></van-col>
            <van-col span="8" class="addclass">
            </van-col>
          </van-row>
        </template>
      </van-card>
    </van-col>
  </van-row>
  <van-submit-bar :price="ShopList.CkeckedPrice" button-text="提交订单" @submit="onSubmit" />
</div>
</template>

<script>
import {Toast} from "vant";
export default {
  name: "order",
  data(){
    return{}
  },
computed:{
    objaddres(){
      return this.$store.getters["address/objaddres"]
    },
  ShopList(){
      return this.$store.getters["cart/shopAtter"]
  },

},
  methods:{
    onSubmit(){
      if(this.objaddres==undefined){
        Toast('收货地址不能为空！')
        return
      }
     let obj={
        address:this.objaddres,
        shop:this.ShopList
     }
      this.$store.commit('cart/removeTrue')
      this.$store.commit('addorder/addsuccessful',obj)
      this.$router.push('/successful')
    },
    onClickLeft(){
      this.$router.back()
    },
    onEdit() {
      this.$router.push('/address')
    },
    onAdd(){
      this.$router.push('/address')
    }
  }
}
</script>

<style scoped lang="less">
.address{position: relative;margin:6px;font-size:12px;box-sizing: border-box;border-bottom:4px #1989fa solid;}
.van-icon-contact:before{
  content:''
}
.span1{font-size:14px}
.icon{position: absolute;top:30%;right:10%;font-size:18px}
.span{padding:4px 0 0 14px}
.addspan{margin-left:14px;background:red;color:white}
.reovm{height:100%;background: red;text-align: center;color: #fafafa;line-height: 132px}
.van-row{background: #fafafa}
.van-col{position: relative}
.van-col>.van-checkbox{position:absolute;top:50%;left: 50%;transform:translateX(-50%)translateY(-50%)}
.van-card__price{font-size:14px}
</style>